home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: External_ARexx.ieb 1.11, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Execute an external arexx script, once for every PRIMARY image. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' 'IE_TO_FRONT' NL = d2c(10) if command = '' then do 'FORM "External Arexx" " OK | Cancel"', ' FILE,"Arexx script","IE:ARexx/Fresco.rexx"', ' CYCLE,"Script type:","This is an IE arexx script.|This is an external script.",0', ' TEXT,"This is the argument line that is passed to non-IE arexx scripts.'NL||, 'Keywords may be used to insert special arguments:'NL||, '%S = source image path.'NL||, '%D = destination image path.'NL||, '%F = current image number.'NL||, '%N = total number of images."', ' STRING,"Argument line","%S %D",200' parse var result ok '"'Script'"' Port '"'argline'"' . if ok = 0 then return '<ERROR>' Script = translate(Script,'¤',' ') Script = translate(Script,'¥','"') argline = translate(argline,'¤',' ') argline = translate(argline,'¥','"') end else do 'REQUEST' '"You can only select an external 'd2c(10)||'arexx script for the first image."' '" OK "' Script = 'none' argline = 'none' Port = 'none' end back = '#'Script '#'argline '#'strip(Port) return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"' parse var options '#'Script '#'argline '#'Port . Script = translate(Script,' ','¤') Script = strip(translate(Script,'"','¥')) if ~exists(Script) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load arexx script:' d2c(10)||Script'"' '" OK "' return '<ERROR>' end if Port = 0 then do 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'PROJECT_LIST' pre_list = result address 'IMAGEENGINEER' interpret 'call' '"'Script'"' '"'LoadImage'"' if (RC>5) then return '<ERROR>' 'PROJECT_LIST' new_list = result do forever parse var pre_list proj pre_list xnew_list = new_list ; new_list = '' do forever parse var xnew_list tproj xnew_list if strip(tproj)=strip(proj) then leave else new_list = new_list tproj if strip(xnew_list) = '' then leave end if strip(pre_list) = '' then leave end OutputImage = strip(new_list) if LoadImage ~= OutputImage then do if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage end 'CLOSE' LoadImage end else do argline = translate(strip(argline),' ','¤') argline = strip(translate(argline,'"','¥')) argline = replace_string(argline,'%S',src_image) argline = replace_string(argline,'%s',src_image) argline = replace_string(argline,'%D',dst_image) argline = replace_string(argline,'%d',dst_image) argline = replace_string(argline,'%F',frame) argline = replace_string(argline,'%f',frame) argline = replace_string(argline,'%N',num_frames) argline = replace_string(argline,'%n',num_frames) address 'COMMAND' 'Rx' Script argline if (RC>5) then return '<ERROR>' end back = 'OK' return back /* Internal procedures ---------------------------------------------- */ replace_string: parse arg rep_str,rep_old,rep_new do while (pos(rep_old,rep_str)~=0) rep_ofs = pos(rep_old,rep_str) rep_str = delstr(rep_str,rep_ofs,length(rep_old)) rep_str = insert(rep_new,rep_str,rep_ofs-1) end /* while */ return rep_str /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'